<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>编辑预警 - Powered By Betou</title>
<meta name="author" content="Betou Team" />
<meta name="copyright" content="Betou" />
<#include "../../head.html"/>
<link href="${base}/res/betou_template/js/jqueryui/jquery.ui.autocomplete.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/thirdparty/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/res/betou_template/js/jqueryui/jquery.ui.autocomplete.min.js"></script>
<script type="text/javascript">
var groups = '${bean.orientedGroup!}';
var smsGroups = '${bean.smsGroups!}';
$().ready(function() {
	$("#inputForm input[name*=userGroup]").each(function() {
		var role = $(this).val();
		
		for(var i=0,len=groups.length;i<len;i++) {
			if(groups[i]==role) {
				$(this).attr("checked",true);
				break;
			}
		}
	});

	$("#inputForm input[name*=smsGroup]").each(function() {
		var role = $(this).val();
		
		for(var i=0,len=smsGroups.length;i<len;i++) {
			if(smsGroups[i]==role) {
				$(this).attr("checked",true);
				break;
			}
		}
	});
	
	var $inputForm = $("#inputForm");
	var $browserButton = $("input.browserButton");
	$browserButton.browser({
			type: "html",
			title:"添加品种", 
			isUpload:true,
			browserUrl:  "../category/v_ajax_add.jspx",
			callback: null
	});
	// 表单验证
	$inputForm.validate({
		rules: {
			userGroup:"required",
			startDate:"required",
			categoryName:{
				required: true,
				remote:{
					url:"../v_check_category.jspx",
					cache:false
				}
			},
			openPosition: {
				required: true,
				min: 0,
				decimal: {
					integer: 12,
					fraction: 2
				}
			},
			stopPosition: {
				required: true,
				min: 0,
				decimal: {
					integer: 12,
					fraction: 2
				}
			},
			longPosition: {
				required: true,
				min: 0,
				decimal: {
					integer: 12,
					fraction: 2
				}
			},
			openReason:{maxlength:1000}
		},
		messages: {
			categoryName: {
				remote: "您所选择的品种不存在"
			}
		}
	});
	
	$( "#categoryName" ).autocomplete({
		source: "../v_list_category.jspx",
		minLength: 1,
		focus: function( event, ui ) {
			$( "#categoryName" ).val( ui.item.name );
			return false;
		},
	
		select: function( event, ui ) {
			$('#categoryName').val( ui.item.name );
			return false;
		}
	}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
			return $( "<li>" ).append( "<a>" + item.name + "</a>" ).appendTo( ul );
	};

	loadSmsNumAndUseNum("send", "smsGroup");
	$("#inputForm input[name*=smsGroup]").click(function(){
		loadSmsNumAndUseNum("send", "smsGroup");
	})
	
});
</script>
</head>
<body class="content">
	<div class="path">
		<a href="../index.jspx">首页</a> &raquo; 编辑预警
	</div>
	<form id="inputForm" action="o_update.jspx" method="post"  >
		<input type="hidden" name="id" value="${bean.id!}" />
		<table class="input tabContent">
			<tr>
				<th><span class="requiredField">*</span>面向用户:</th>
				<td>
					<span class="fieldSet"> 
						<#list groupList as c>
							<label><input type="checkbox" name="userGroup" value="${c.id!}"/>${c.name!}</label>
						</#list>
					</span>
				</td>
			</tr>
			<tr>
				<th>短信发送:</th>
				<td>
					<span class="fieldSet"> 
						<#list groupList as c>
							<label><input type="checkbox" name="smsGroup" value="${c.id!}"/>${c.name!}</label>
						</#list>
					</span>
				</td>
			</tr>
			<tr>
				<th>设置:</th>
				<td>
					<span class="fieldSet"> 
						<label><input type="checkbox" name="send" value="true" checked/>立即发送短信</label>
						&nbsp;<span id="loading" class="green">正在加载短信信息...</span>
					</span>
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>喊单品种:</th>
				<td>
					<input name="categoryName"  type="text"  class="text" id="categoryName"  value="${bean.category.name!}" maxlength="50" />
					<input type="button" value="添加品种" class="button browserButton" />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>喊单方向:</th>
				<td>
					<select name="direction">
						<option value="1" <#if bean.direction> selected</#if> >空单</option>
						<option value="0" <#if !bean.direction> selected</#if> >多单</option>
					</select>
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>开仓点位:</th>
				<td>
					<input type="text" name="openPosition" class="text"  value="${bean.openPosition!}" />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>止损点位:</th>
				<td>
					<input type="text" name="stopPosition" class="text"  value="${bean.stopPosition!}"  />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>止盈点位:</th>
				<td>
					<input type="text" name="longPosition" class="text"  value="${bean.longPosition!}" />
				</td>
			</tr>
			<tr>
				<th><span class="requiredField">*</span>开仓时间:</th>
				<td>
					<input type="text" name="startDate" class="text Wdate" readonly="readonly"  onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})"  maxlength="100" value="${bean.startDate?string('yyyy-MM-dd hh:mm:ss')}"  />
				</td>
			</tr>
			<tr>
				<th>开仓理由:</th>
				<td>
						<textarea name="openReason" class="text">${bean.openReason!}</textarea>
				</td>
			</tr>
		</table>
		
		<table class="input">
			<tr>
				<th>&nbsp;</th>
				<td>
					<input type="submit" class="button" value="确&nbsp;&nbsp;定" />
					<input type="button" class="button" value="返&nbsp;&nbsp;回" onclick="location.href='v_list.jspx'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
